package com.headwind.logistics.carrier.service.impl;

import com.headwind.logistics.carrier.dto.CarRegisterDto;
import com.headwind.logistics.carrier.mapper.CarRegisterMapper;
import com.headwind.logistics.carrier.service.inter.CarRegisterServiceInter;
import com.headwind.logistics.common.pojo.CarRegister;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author QT
 * @Date 2020/7/24 15:05
 * @Version 1.0
 * @DESCRIPTION 车辆登记业务逻辑层接口
 */
@Service
public class CarRegisterServiceImpl implements CarRegisterServiceInter {
    //车辆登记数据访问层
    @Resource
    private CarRegisterMapper carRegisterMapper;

    /**
     * 查询车辆登记表数据和模糊查询并分页
     * @param tansportName 运输人名字
     * @param page 页码
     * @param rows 行数
     * @return
     */
    @Override
    public List<CarRegisterDto> queryAllCarRegister(String tansportName, Integer page, Integer rows) {
        if (page != null){
            page = (page-1)*rows;
        }
        return carRegisterMapper.queryAllCarRegister(tansportName,page,rows);
    }

    /**
     * 修改车辆登记状态
     * @param carRegister 车辆登记实体对象
     * @return
     */
    @Override
    public int updateCarRegisterStatus(CarRegister carRegister) {
        int count= carRegisterMapper.updateCarRegisterStatus(carRegister);
        return count;
    }
}
